# -*- coding: utf-8 -*-

'''

@author: wyndem
@Emil:   wyndem.wen@timevary.com
@FileName: chapter_6.py
@Time: 2018/6/25 10:13
@Description:广度优先搜索 --图

'''
from collections import deque

graph = {}
graph['you'] = ['alice', 'bob', 'claire']
graph['bob'] = ['anuj', 'peggy']
graph['claire'] = ['adasda', 'asdadafgafa']
graph['asdadafgafa']=['asdam']


def plan():
    graph = {}
    graph['you'] = ['alice', 'bob', 'claire']
    graph['bob'] = ['anuj', 'peggy']
    print(graph.get(graph.get('you')[1]))

def person_is_seller(name):
    return name[-1]=='m'


if __name__ == '__main__':
    search_queue=deque()
    search_queue+=graph['you']
    searched=[]
    while search_queue:
        person=search_queue.popleft()
        if person_is_seller(person) and (not person in searched):
           print('%s is a mango seller'%person)
        else:
            try:
                search_queue+=graph[person]
            except KeyError as s:
                pass
            finally:
                searched.append(person)





